/**
 * Created by fangshufeng on 2017/12/8.
 */

import QuestSerializer from  'qs'

const BaseDomain = 'http://192.168.28.37';
const Port = '3000';
const basePath = 'fetchMockData';

export let MockGET = function (urlString, parameters) {
    let fetchOptions = {
        method: 'GET',
    };

    let url = BaseDomain + ':' + Port + '/' + urlString;
    let parameterStr = QuestSerializer.stringify(parameters);
    if (parameterStr.length > 0) {
        url =  url +  '?' + parameterStr;
    }
    return fetch(url, fetchOptions);
};

export let MockPOST = function (urlString, parameters) {

    let fetchOptions = {
        method: 'POST',
        body:QuestSerializer.stringify(parameters),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
    };
    console.log('1122',QuestSerializer.stringify(parameters));
    let url = BaseDomain + ':' + Port + '/' + urlString ;
    return fetch(url, fetchOptions);
};

export let BaseDominAndPort =  BaseDomain + ':' + Port + '/';

export let BasePath = basePath;